//
//  InvestTableViewCell.m
//  B-72K
//
//  Created by sos on 16/3/7.
//  Copyright © 2016年 sos. All rights reserved.
//

#import "InvestTableViewCell.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>
#import "AllPrefixHeader.pch"
@implementation InvestTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self data];
        
    }
    return self;
}
- (void)data
{
    UIImageView * tupian = [UIImageView new];
    [self.contentView addSubview:tupian];
    self.tupian = tupian;
    
    
    UILabel *content = [UILabel new];
    content.numberOfLines = 0;
    content.font = [UIFont fontWithName:@"" size:13];
    [self.contentView addSubview:content];
    self.content = content;
    [self.content NightWithType:UIViewColorTypeNormal];
    
    UIImageView *touxiang = [UIImageView new];
    [self.tupian addSubview:touxiang];
    touxiang.layer.cornerRadius = 25;
    
    self.touxiang = touxiang;
    touxiang.clipsToBounds = YES;
    
    UILabel *name = [UILabel new];
    [self.tupian addSubview:name];
    self.name = name;
    
    UILabel *attribute = [UILabel new];
    [self.contentView addSubview:attribute];
    self.attribute = attribute;
    [_attribute NightWithType:UIViewColorTypeNormal];
    
    UILabel *ing = [UILabel new];
    [self.contentView addSubview:ing];
    self.ing = ing;
    

    UILabel *number = [UILabel new];
    [self.contentView addSubview:number];
    number.textAlignment = NSTextAlignmentLeft;
    self.number = number;
    
    
    __weak __typeof(&*self)weakSelf = self;
    
    [self.tupian mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(180);
//        make.width.mas_equalTo(weakSelf.mas_width).offset(0);
        make.top.equalTo(weakSelf.mas_top).offset(5);
        make.left.equalTo(weakSelf.mas_left).offset(0);
        make.right.equalTo(weakSelf.mas_right).offset(0);
    }];
    
    [self.touxiang mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(50);
        make.width.mas_equalTo(50);
        make.top.equalTo(tupian.mas_top).offset(120);
        make.left.equalTo(tupian.mas_left).offset(10);
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(70);
        make.top.equalTo(touxiang.mas_top).offset(15);
        make.left.equalTo(touxiang.mas_right).offset(10);
        
    }];
    [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.height.mas_equalTo(180);
        //        make.width.mas_equalTo(weakSelf.mas_width).offset(0);
        make.top.equalTo(tupian.mas_bottom).offset(5);
        make.left.equalTo(weakSelf.mas_left).offset(0);
        make.right.equalTo(weakSelf.mas_right).offset(0);
        make.bottom.equalTo(ing.mas_top).offset(-5);

        
    }];
    
    [self.ing mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(40);
        make.bottom.equalTo(weakSelf.mas_bottom).offset(-5);
        make.left.equalTo(weakSelf.mas_left).offset(5);
    }];
    [self.number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(130);
        make.bottom.equalTo(weakSelf.mas_bottom).offset(- 5);
        make.left.equalTo(ing.mas_right).offset(0);
    }];
    [self.attribute mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(60);
        make.bottom.equalTo(weakSelf.mas_bottom).offset(-5);
        make.right.equalTo(weakSelf.mas_right).offset(-10);
    }];
    
    
    
}
- (void)setInvest:(InvestModel *)invest
{
    _invest = invest;
    _content.text = _invest.alias;
    [_touxiang sd_setImageWithURL:[NSURL URLWithString:_invest.headpicurl]placeholderImage:[UIImage imageNamed:@""]];
    _name.text = _invest.name;
    
    _name.textColor = [UIColor whiteColor];
    
    [_tupian sd_setImageWithURL:[NSURL URLWithString:_invest.picurl]placeholderImage:[UIImage imageNamed:@""]];
    _number.text= [NSString stringWithFormat:@"%@关注",_invest.concernCount];
    _number.font = [UIFont systemFontOfSize:12];
    [_number NightWithType:UIViewColorTypeNormal];


    _number.textAlignment = NSTextAlignmentLeft;
    _attribute.text = _invest.classification;
    _attribute.textAlignment = NSTextAlignmentRight;
    _attribute.font = [UIFont systemFontOfSize:12];


    _ing.text = @"进行中";
    [_ing NightWithType:UIViewColorTypeNormal];
    _ing.textAlignment = NSTextAlignmentLeft;
    _ing.font = [UIFont systemFontOfSize:12];

    
    
    

    
}




/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
